Skip to content

Conversation

@lehnerpat
Copy link
Contributor

@lehnerpat lehnerpat commented Apr 20, 2019

By using the footnoteReference label property instead of its identifier (which must be shared between the footnoteReference and the footnoteDefinition for the links between them to work), remark plugins can easily change the display text for footnote references.

Edit: Note that because of the way that remark computes identifier vs label of footnoteReference, this causes a minor change to the default label text of rendered footnote references (but only for separately defined references and definitions, not for inline footnotes). The label text is now what is actually used as footnote ID in the source, not the identifier-ized version.

…erences

By using the `footnoteReference` label property instead of its identifier (which must be shared between the footnoteReference and the footnoteDefinition for the links between them to work), remark plugins can easily change the display text for footnote references.
Copy link
Member

@wooorm wooorm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! Appreciated!

I’m suggesting a simpler mechanism that would still allow the label to be used, but default to the identifier if label isn’t there.

Normally, from remark-parse, an identifier is for example foo, whereas the label could in that case be Foo. In other words, typically the casing is different. Could you add a test for this?

@lehnerpat
Copy link
Contributor Author

Thanks for your feedback @wooorm!

I've made the changes you requested to make the implementation a bit simpler.
I also added a test for label and identifier being different cases (or more generally, for label and identifier being different), in which case the label should be used.
I also took the liberty of removing some line breaks from test/footnoteReference.js to improve readability and style it like test/footnote.js -- I hope that's alright.

@wooorm
Copy link
Member

wooorm commented Apr 22, 2019

Nice! Thanks Patrick!

@wooorm wooorm merged commit 795af36 into syntax-tree:master Apr 28, 2019
@wooorm wooorm added ⛵️ status/released 🐛 type/bug This is a problem 🗄 area/interface This affects the public interface 🧑 semver/major This is a change labels Aug 11, 2019
jlengstorf added a commit to jlengstorf/zmarkdown that referenced this pull request Aug 24, 2019
As of syntax-tree/mdast-util-to-hast#31, the footnote label is used for footnotes instead of its identifier. This change brings back numbered footnotes correctly.
@wooorm wooorm added the 💪 phase/solved Post is done label Apr 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🗄 area/interface This affects the public interface 💪 phase/solved Post is done 🧑 semver/major This is a change 🐛 type/bug This is a problem

Development

Successfully merging this pull request may close these issues.

3 participants